#############################################
# 1 项目配置
#############################################

cmake_minimum_required( VERSION 3.0.0 )
project( STL_Mysql VERSION 0.1.0 )


#############################################
# 2 路径配置
#############################################

# make时的可执行文件输出路径
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/output)

# 设置安装根目录
SET(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/install)



# SET(DESTINATION ${PROJECT_SOURCE_DIR}/install)
message(STATUS "=======================================")
message(STATUS "路径设置")
message(STATUS "---------------------------------------")
message(STATUS "PROJECT_NAME:${PROJECT_NAME}")
message(STATUS "PROJECT_BINARY_DIR:${PROJECT_BINARY_DIR}")
message(STATUS "PROJECT_SOURCE_DIR:${PROJECT_SOURCE_DIR}")
message(STATUS "CMAKE_INSTALL_PREFIX:${CMAKE_INSTALL_PREFIX}")
# message(STATUS "DESTINATION:${DESTINATION}")
message(STATUS "---------------------------------------")


#############################################
# 3 编译选项
#############################################
set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -g")
# set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-stack-check")

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-check")


add_definitions(
    -DLYL_DEBUG
)

#############################################
# 4 头文件搜索路径
#############################################

# # srs_rtmp头文件路径
# include_directories(
#     "/home/liuyuelong/libs_git/srs.git/trunk/objs/include"
#     # "./libs/srs_rtmp/include"
# )

# # openssl头文件路径
# include_directories(
#     "./libs/openssl/include"
# )

# # mosquitto头文件路径
# include_directories(
#     "/opt/data/sip/mqtt_lib/include"
#     "./libs/mosquitto/include"
# )

# # jsoncppt头文件路径
# include_directories(
#     "/opt/data/sip/jsoncpp/include"
# )

# 库头文件头文件路径
# include_directories(
#     # "/Users/liuyuelong/Workspace/LibsGit/BuisBuild.git/ffmpeg/buildForMac/dist20200920105536/include"
#     # "/opt/data/sip/ffmpeg_lib/include"
#     # "/opt/data/sip/jrtp/jrtplib_debug/include"
#     # "/opt/data/sip/yaml-cpp/include"
#     # "/opt/data/log/zlog-1.2.14/src"
# )

# # stl_utils头文件路径
# include_directories(
#     "./libs/stl_utils/src/"
# )



# include_directories(
#     # "./libs/libpsmux/inc/"
#     # "./libs/stl_utils/libs/jsoncpp/json/"
#     # "./libs/stl_utils/libs/tinyxml/"
# )

# stl_utils
include_directories(
    ".."
)

message(STATUS "=======================================")
message(STATUS "头文件搜索路径")
message(STATUS "---------------------------------------")
foreach(src_filename ${INCLUDE_DIRECTORIES})
    message(STATUS ${src_filename})
endforeach(src_filename)
message(STATUS "---------------------------------------")

#############################################
# 5 库文件搜索路径
#############################################

# # ffmpeg库路径
# link_directories(
#     "/opt/data/sip/ffmpeg_lib/lib"
#     # "/Users/liuyuelong/Workspace/LibsGit/BuisBuild.git/ffmpeg/buildForMac/dist20200920105536/lib"
# )


# # srs_rtmp库路径
# link_directories(
#     # "/home/liuyuelong/workspace/RtmpReceiveStream/libs/srs_rtmp/lib"
#     "/home/liuyuelong/libs_git/srs.git/trunk/objs/lib"
# )

# # openssl库路径
# link_directories(
#     "./libs/openssl/lib"
# )

# yaml-cpp库路径
# link_directories(
#     "/opt/data/sip/yaml-cpp/build"
# )

# jrtp库路径
# link_directories(
#     # "/opt/data/sip/jrtp/jrtplib_debug/lib"
#     "/opt/data/sip/jrtp/jrtplib-3.11.1_org_no_thread/src"
# )

# exosip库路径
# link_directories(
#     "/opt/data/sip/exosip/libosip2-5.0.0/src/osipparser2/.libs"
#     "/opt/data/sip/exosip/libosip2-5.0.0/src/osip2/.libs"
#     "/opt/data/sip/exosip/libexosip2-5.0.0/src/.libs"
# )

# eXosip库路径
# link_directories(
#     # "/opt/data/sip/jrtp/jrtplib_debug/lib"
#     "/opt/data/sip/jrtp/jrtplib-3.11.1_org_no_thread/src"
# )

# # zlog库路径
# link_directories(
#     "/opt/data/log/zlog-1.2.14/src"
# )


# # mosquitto库路径
# link_directories(
#     "/opt/data/sip/mqtt_lib/lib"
#     "/home/liuyuelong/workspace/TestGBA9300/libs/mosquitto/lib"
#     # "opt/data/sip/mosquitto-1.6.9/build/lib/cpp/"
# )

# # jsoncpp库路径
# link_directories(
#     "/opt/data/sip/jsoncpp/build/debug/src/lib_json"
# )


message(STATUS "=======================================")
message(STATUS "库搜索路径")
message(STATUS "---------------------------------------")
foreach(src_filename ${LINK_DIRECTORIES})
    message(STATUS ${src_filename})
endforeach(src_filename)
message(STATUS "---------------------------------------")


#############################################
# 6 源码路径
#############################################

aux_source_directory(./src SRC_LIST)

# aux_source_directory(./src/HLSRecord SRC_LIST)
# aux_source_directory(./src/FFmpegRtspClient SRC_LIST)
# aux_source_directory(./src/GBSMS SRC_LIST)
# aux_source_directory(./src/GBClient SRC_LIST)
# aux_source_directory(./src/manscdp SRC_LIST)
# aux_source_directory(./src/GBSvrManager SRC_LIST)
# aux_source_directory(./src/PsMuxer SRC_LIST)
# aux_source_directory(./src/RtpSender SRC_LIST)
# aux_source_directory(./src/RtspClient SRC_LIST)
# aux_source_directory(./src/tools SRC_LIST)

# 源码库
aux_source_directory("." SRC_LIST)
aux_source_directory(".." SRC_LIST)
# aux_source_directory(./libs/libpsmux/src SRC_LIST)
# aux_source_directory(./libs/stl_utils/src/STL_Path SRC_LIST)
# aux_source_directory(./libs/stl_utils/src/STL_Timestamp SRC_LIST)
# aux_source_directory(./libs/stl_utils/src/STL_FS SRC_LIST)
# aux_source_directory("./libs/stl_utils/src/TSL_Text" SRC_LIST)
# aux_source_directory(./libs/stl_utils/src/STL_YAML SRC_LIST)
# aux_source_directory(./libs/stl_utils/src/STL_XML SRC_LIST)
# aux_source_directory(.libs/stl_utils/libs/jsoncpp SRC_LIST)
# aux_source_directory(./libs/stl_utils/libs/tinyxml SRC_LIST)


message(STATUS "=======================================")
message(STATUS "项目源文件列表")
message(STATUS "---------------------------------------")
foreach(src_filename ${SRC_LIST})
    message(STATUS ${src_filename})
endforeach(src_filename)
message(STATUS "---------------------------------------")

#############################################
# 7 目标生成
#############################################
message(STATUS "=======================================")
message(STATUS "目标文件")
message(STATUS "---------------------------------------")
message(STATUS ${PROJECT_NAME})
message(STATUS "---------------------------------------")
add_executable( ${PROJECT_NAME} ${SRC_LIST} )

#############################################
# 8 连接动态库静态库
#############################################

# # ffmpeg库链接
# target_link_libraries(
#     ${PROJECT_NAME} 
#     -lavformat
#     -lavcodec
#     -lavutil
# )

# # jrtp库链接
# target_link_libraries(
#     ${PROJECT_NAME} 
#     -ljrtp
# )

# # yaml-cpp库链接
# target_link_libraries(
#     ${PROJECT_NAME} 
#     -lyaml-cpp
# )

# pthread库链接
target_link_libraries(
    ${PROJECT_NAME}
    -lpthread
)

# # srs_librtmp
# target_link_libraries(
#     ${PROJECT_NAME}
#     "/home/liuyuelong/libs_git/srs.git/trunk/objs/lib/srs_librtmp.a"
# )

# # openssl库链接
# target_link_libraries(
#     ${PROJECT_NAME}
#     -lssl
#     -lcrypto
# )

# # osip2与eXosip2库链接
# target_link_libraries(
#     ${PROJECT_NAME}
#     -losip2
#     -losipparser2
#     -leXosip2
# )

# # zlog库链接
# target_link_libraries(
#     ${PROJECT_NAME}
#     -lzlog
# )


# # mosquitto库链接
# target_link_libraries(
#     ${PROJECT_NAME}
#     -lmosquitto
#     -lmosquittopp
# )

# # jsoncpp库链接
# target_link_libraries(
#     ${PROJECT_NAME}
#     -ljsoncpp
# )

# jsoncpp库链接
target_link_libraries(
    ${PROJECT_NAME}
    -lmysqlclient
)



#############################################
# 9 安装配置
#############################################

# make install时的可执行文件输出路径（相对于CMAKE_INSTALL_PREFIX的目录）
# install(TARGETS ${PROJECT_NAME} DESTINATION bin)
install(TARGETS ${PROJECT_NAME} DESTINATION .) 

#############################################
# 结束
#############################################
